package com.sayimo.maker.mall.goods.dao.impl;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.sayimo.framework.database.mybatis.AbstractMybatisBaseDao;
import com.sayimo.framework.exception.DaoException;
import com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao;
import com.sayimo.maker.mall.goods.vo.GoodsClass;



/**
 * @Project: schoolmallapi
 * @ClassName: GoodsClassInterfaceImplDao
 * @Description: 商品分类dao
 * @Author:	曹频辉
 * @Date:	日期：2015年12月26日  时间：下午3:48:46
 * @Version 1.0.0
 */
@Repository(value="goodsClassInterfaceImplDao")
public class GoodsClassInterfaceImplDao extends AbstractMybatisBaseDao<GoodsClass> implements GoodsClassInterfaceDao{
	
	
	/**
	* @Title: getGoodsListByClassId 
	* @Description: 根据分类ID查询商品列表
	* @param classId
	* @param goodsName
	* @throws DaoException
	* @return List
	 */
	@Override
	public List getGoodsListByClassId(Integer classId ,String goodsName,Integer sortWord,Integer sortMode,Integer brandId,Integer pageSize,Integer pageNow,Integer providerId) throws DaoException {
		Map map=new HashMap();
		map.put("classId", classId);
		map.put("sortWord", sortWord);
		map.put("sortMode", sortMode);
		map.put("brandId", brandId);
		map.put("pageSize", pageSize);
		map.put("pageNow", pageNow);
		map.put("providerId", providerId);
		if (StringUtils.isNotEmpty(goodsName)) {
			map.put("goodsName", goodsName.replace(" ", ""));
		}
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getGoodsListByClassId", map);
	}
	
	/**
	* @Title: getGoodsClassById 
	* @Description: 根据分类ID查询商品分类
	* @param classId
	* @throws DaoException
	* @return GoodsClass
	 */
	@Override
	public GoodsClass getGoodsClassById(Integer classId) throws DaoException {
		return this.mybatisInterfaceBaseDao.get("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getGoodsClassById",classId);
	}
	
	
	/**
	 * 
	* @Title: getFirstLevelGoodsClassList 
	* @Description: 获得一级分类列表
	* @return
	* @throws DaoException
	* @return List
	* @throws
	 */
	@Override
	public List getFirstLevelGoodsClassList() throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getFirstLevelGoodsClassList",null);
	}
	
	/**
	 * 
	* @Title: getSecondLevelGoodsClassList 
	* @Description:  获得二级分类列表
	* @return
	* @throws DaoException
	* @return List
	* @throws
	 */
	@Override
	public List getSecondLevelGoodsClassList(Integer parentId) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getSecondLevelGoodsClassList",parentId );
	}
	
	/**
	 * 
	* @Title: getThirdLevelGoodsClassList 
	* @Description:  获得三级分类列表
	* @param parentId
	* @return
	* @throws DaoException
	* @return List
	* @throws
	 */
	@Override
	public List getThirdLevelGoodsClassList(Integer parentId)
			throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getThirdLevelGoodsClassList", parentId);
	}
	
	/** 
	  * @package com.sayimo.school.mall.module.goods.dao.impl
	  * @author chenpy
	  * @Title:  
	  * @Description: 
	  * @param 
	  * @throws 
	  * @return List
	  * @date 2016年6月29日
	  */ 
	public List getGoodsClassesByPid(Integer parentId) throws DaoException{
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getGoodsClassesByPid", parentId);
	}

	@Override
	public List getBrandListByClassId(Integer classId) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getBrandListByClassId", classId);
	}

	@Override
	public Map getGoodsClassIdsPolyProviderId(Map paramMap) throws DaoException {
		return (Map) this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getGoodsClassIdsPolyProviderId", paramMap);
	}

	@Override
	public List getProviderClassList(String classIds) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getGoodsClassIdsPolyProviderId", classIds);
	}

	
	@Override
	public List getGoodsClassesById(Integer id) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsClassInterfaceDao.getGoodsClassesById", id);
	}

}
